<template>
	<view>
		<block v-if="isload">
			<view class="banner" :style="{background:'url('+pre_url+'/static/img/topbg.png)',backgroundSize:'100%'}">
				<image :src="set.logo" background-size="cover" @tap="goto"
					:data-url="uinfo.bid==0 ? '/pages/index/index' : '/pages/business/index?id='+uinfo.bid" />
				<view class="info">
					<text class="nickname">{{set.name}}</text>
					<text>{{uinfo.un}}</text>
				 <view class="recharge" v-if="showrecharge" @tap="goto" data-url="recharge">充值</view>
				</view>
				<view class="set" @tap="saoyisao">
					<image src="/static/img/ico-scan.png"></image>
				</view>
			</view>
			<view class="contentdata">
				<block v-if="auth_data.order">
					<view class="order" v-if="showshoporder">
						<view class="head">
							<text class="f1">Mall order</text>
							<view class="f2" @tap="goto" data-url="../order/shoporder"><text>View all orders</text>
								<image src="/static/img/arrowright.png"></image>
							</view>
						</view>
						<view class="content">
							<view class="item" @tap="goto" data-url="../order/shoporder?st=0">
								<image src="/static/img/order1.png"></image>
								<text class="t3">Pending payment({{count0}})</text>
							</view>
							<view class="item" @tap="goto" data-url="../order/shoporder?st=1">
								<image src="/static/img/order2.png"></image>
								<text class="t3">Pending Shipment({{count1}})</text>
							</view>
							<view class="item" @tap="goto" data-url="../order/shoporder?st=2">
								<image src="/static/img/order3.png"></image>
								<text class="t3">pending receipt({{count2}})</text>
							</view>
							<view class="item" @tap="goto" data-url="../order/shopRefundOrder">
								<image src="/static/img/order4.png"></image>
								<text class="t3">Refund/Aftermarket({{count4}})</text>
							</view>
						</view>
					</view>

					<view class="list">
						<view class="item" @tap="goto" data-url="./recharge">
							<view class="f2">my top up</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
					</view>

					<view class="list">
						<view class="item" @tap="goto" data-url="../order/collageorder" v-if="showcollageorder">
							<view class="f2">Group order</view>
							<text class="f3">{{collageCount}}</text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view class="item" @tap="goto" data-url="../order/kanjiaorder" v-if="showkanjiaorder">
							<view class="f2">Bargaining order</view>
							<text class="f3">{{kanjiaCount}}</text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view class="item" @tap="goto" data-url="../order/seckillorder" v-if="showseckillorder">
							<view class="f2">Seckill order</view>
							<text class="f3">{{seckillCount}}</text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view class="item" @tap="goto" data-url="../order/tuangouorder" v-if="showtuangouorder">
							<view class="f2">Group purchase order</view>
							<text class="f3">{{tuangouCount}}</text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view class="item" @tap="goto" data-url="../order/scoreshoporder" v-if="showscoreshoporder">
							<view class="f2">{{t('points')}}Mall order</view>
							<text class="f3">{{scoreshopCount}}</text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view class="item" @tap="goto" data-url="../order/luckycollageorder"
							v-if="showluckycollageorder">
							<view class="f2">Lucky Group Order</view>
							<text class="f3">{{luckycollageCount}}</text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view class="item" @tap="goto" data-url="../form/formlog" v-if="showformlog">
							<view class="f2">form submission record</view>
							<text class="f3">{{formlogCount}}</text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view class="item" @tap="goto" data-url="../order/yuyueorder" v-if="showyuyueorder">
							<view class="f2">reservation order</view>
							<text class="f3">{{yuyueorderCount}}</text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>

					</view>
				</block>

				<view class="list" v-if="showworkorder">
					<view class="item" @tap="goto" data-url="../workorder/record">
						<view class="f2">Work order record</view>
						<text class="f3">{{workordercount}}</text>
						<image src="/static/img/arrowright.png" class="f4"></image>
					</view>
				</view>

				<block v-if="auth_data.product">
					<view class="list">
						<view class="item" @tap="goto" data-url="../product/index">
							<view class="f2">Product list</view>
							<text class="f3">{{productCount}}</text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view class="item" @tap="goto" data-url="../product/edit">
							<view class="f2">Adding goods</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
					</view>
				</block>

				<block
					v-if="auth_data.restaurant_product || auth_data.restaurant_table || auth_data.restaurant_tableWaiter">
					<view class="list">
						<view v-if="auth_data.restaurant_product" class="item" @tap="goto"
							data-url="../restaurant/product/index">
							<view class="f2">Dishes list</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view v-if="auth_data.restaurant_product" class="item" @tap="goto"
							data-url="../restaurant/product/edit">
							<view class="f2">add dishes</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view v-if="auth_data.restaurant_product" class="item" @tap="goto"
							data-url="../restaurant/category/index">
							<view class="f2">Category of dishes</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view v-if="auth_data.restaurant_product" class="item" @tap="goto"
							data-url="../restaurant/category/edit">
							<view class="f2">add category</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view v-if="auth_data.restaurant_table" class="item" @tap="goto"
							data-url="../restaurant/tableCategory">
							<view class="f2">Dining table classification</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view v-if="auth_data.restaurant_table" class="item" @tap="goto" data-url="../restaurant/table">
							<view class="f2">dining table edit</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view v-if="auth_data.restaurant_tableWaiter" class="item" @tap="goto"
							data-url="../restaurant/tableWaiter">
							<view class="f2">table management</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
					</view>
				</block>
				<block
					v-if="auth_data.restaurant_takeaway || auth_data.restaurant_shop || auth_data.restaurant_booking || auth_data.restaurant_deposit || auth_data.restaurant_queue">
					<view class="list">
						<view v-if="auth_data.restaurant_takeaway" class="item" @tap="goto"
							data-url="../restaurant/takeawayorder">
							<view class="f2">Takeaway order</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view v-if="auth_data.restaurant_shop" class="item" @tap="goto"
							data-url="../restaurant/shoporder">
							<view class="f2">food order</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view v-if="auth_data.restaurant_booking" class="item" @tap="goto"
							data-url="../restaurant/bookingorder">
							<view class="f2">Book an order</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view v-if="auth_data.restaurant_booking" class="item" @tap="goto"
							data-url="../restaurant/booking">
							<view class="f2">Add reservation</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view v-if="auth_data.restaurant_deposit" class="item" @tap="goto"
							data-url="../restaurant/depositorder">
							<view class="f2">Deposit order</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view v-if="auth_data.restaurant_queue" class="item" @tap="goto" data-url="../restaurant/queue">
							<view class="f2">queuing up</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
						<view v-if="auth_data.restaurant_queue" class="item" @tap="goto"
							data-url="../restaurant/queueCategory">
							<view class="f2">queue management</view>
							<text class="f3"></text>
							<image src="/static/img/arrowright.png" class="f4"></image>
						</view>
					</view>
				</block>

				<view class="list">
					<view class="item" @tap="goto" data-url="../hexiao/record">
						<view class="f2">my write-off</view>
						<text class="f3">{{hexiaoCount}}</text>
						<image src="/static/img/arrowright.png" class="f4"></image>
					</view>
				</view>

				<view class="list">
					<view class="item" v-if="uinfo.tmpl_orderconfirm_show==1">
						<view class="f2">Order Submission Notification</view>
						<view class="f3">
							<switch value="1" :checked="uinfo.tmpl_orderconfirm==1?true:false" @change="switchchange"
								data-type="tmpl_orderconfirm"></switch>
						</view>
					</view>
					<view class="item" v-if="uinfo.tmpl_orderpay_show==1">
						<view class="f2">Order payment notification</view>
						<view class="f3">
							<switch value="1" :checked="uinfo.tmpl_orderpay==1?true:false" @change="switchchange"
								data-type="tmpl_orderpay"></switch>
						</view>
					</view>
					<view class="item" v-if="uinfo.tmpl_ordershouhuo_show==1">
						<view class="f2">Order Receipt Notification</view>
						<view class="f3">
							<switch value="1" :checked="uinfo.tmpl_ordershouhuo==1?true:false" @change="switchchange"
								data-type="tmpl_ordershouhuo"></switch>
						</view>
					</view>
					<view class="item" v-if="uinfo.tmpl_ordertui_show==1">
						<view class="f2">Notice of Refund Request</view>
						<view class="f3">
							<switch value="1" :checked="uinfo.tmpl_ordertui==1?true:false" @change="switchchange"
								data-type="tmpl_ordertui"></switch>
						</view>
					</view>
					<view class="item" v-if="uinfo.tmpl_withdraw_show==1">
						<view class="f2">Withdrawal Application Notification</view>
						<view class="f3">
							<switch value="1" :checked="uinfo.tmpl_withdraw==1?true:false" @change="switchchange"
								data-type="tmpl_withdraw"></switch>
						</view>
					</view>
					<view class="item" v-if="uinfo.tmpl_formsub_show==1">
						<view class="f2">form submission notification</view>
						<view class="f3">
							<switch value="1" :checked="uinfo.tmpl_formsub==1?true:false" @change="switchchange"
								data-type="tmpl_formsub"></switch>
						</view>
					</view>
					<view class="item" v-if="uinfo.tmpl_kehuzixun_show==1">
						<view class="f2">User Advisory Notice</view>
						<view class="f3">
							<switch value="1" :checked="uinfo.tmpl_kehuzixun==1?true:false" @change="switchchange"
								data-type="tmpl_kehuzixun"></switch>
						</view>
					</view>
				</view>
				<view class="list">
					<view v-if="showbusinessqr" class="item" @tap="goto" data-url="businessqr">
						<view class="f2">Promotion invitation code</view>
						<text class="f3"></text>
						<image src="/static/img/arrowright.png" class="f4"></image>
					</view>
					<view v-if="showbusinessqr" class="item" @tap="goto" data-url="businessqr">
						<view class="f2">Promotion invitation code</view>
						<text class="f3"></text>
						<image src="/static/img/arrowright.png" class="f4"></image>
					</view>
					<view class="item" @tap="goto" data-url="../workorder/add" v-if="showworkadd">
						<view class="f2">work order submission</view>
						<text class="f3"></text>
						<image src="/static/img/arrowright.png" class="f4"></image>
					</view>
					<view class="item" @tap="goto" data-url="setinfo" v-if="uinfo.bid>0">
						<view class="f2">Store settings</view>
						<text class="f3"></text>
						<image src="/static/img/arrowright.png" class="f4"></image>
					</view>
					<view class="item" @tap="goto" data-url="setpwd">
						<view class="f2">change Password</view>
						<text class="f3"></text>
						<image src="/static/img/arrowright.png" class="f4"></image>
					</view>
					<view class="item" @tap="goto" data-url="../index/login">
						<view class="f2">switch account</view>
						<text class="f3"></text>
						<image src="/static/img/arrowright.png" class="f4"></image>
					</view>
				</view>
			</view>

			<view class="tabbar">
				<view class="tabbar-bot"></view>
				<view class="tabbar-bar" style="background-color:#ffffff">
					<view @tap="goto" data-url="../member/index" data-opentype="reLaunch" class="tabbar-item"
						v-if="auth_data.member">
						<view class="tabbar-image-box">
							<image class="tabbar-icon" src="/static/img/member.png"></image>
						</view>
						<view class="tabbar-text">{{t('membership')}}</view>
					</view>
					<view @tap="goto" data-url="../kefu/index" data-opentype="reLaunch" class="tabbar-item"
						v-if="auth_data.zixun">
						<view class="tabbar-image-box">
							<image class="tabbar-icon" src="/static/img/zixun.png"></image>
						</view>
						<view class="tabbar-text">consult</view>
					</view>
					<view @tap="goto" data-url="../finance/index" data-opentype="reLaunch" class="tabbar-item"
						v-if="auth_data.finance">
						<view class="tabbar-image-box">
							<image class="tabbar-icon" src="/static/img/finance.png"></image>
						</view>
						<view class="tabbar-text">financial affairs</view>
					</view>
					<view @tap="goto" data-url="../index/index" data-opentype="reLaunch" class="tabbar-item">
						<view class="tabbar-image-box">
							<image class="tabbar-icon" src="/static/img/my2.png"></image>
						</view>
						<view class="tabbar-text active">my</view>
					</view>
				</view>
			</view>
		</block>
		<popmsg ref="popmsg"></popmsg>
	</view>
</template>

<script>
	var app = getApp();
	export default {
		data() {
			return {
				opt: {},
				loading: false,
				isload: false,
				menuindex: -1,
				pre_url: app.globalData.pre_url,

				set: {},
				uinfo: {},
				count0: 0,
				count1: 0,
				count2: 0,
				count3: 0,
				count4: 0,
				seckillCount: 0,
				collageCount: 0,
				kanjiaCount: 0,
				tuangouCount: 0,
				scoreshopCount: 0,
				maidanCount: 0,
				productCount: 0,
				yuyueorderCount: 0,
				hexiaoCount: 0,
				formlogCount: 0,
				auth_data: {},
				showshoporder: false,
				showbusinessqr: false,
				showyuyueorder: false,
				showcollageorder: false,
				showkanjiaorder: false,
				showseckillorder: false,
				showscoreshoporder: false,
				showluckycollageorder: false,
				showtuangouorder: false,
				showformlog: false,
				showworkorder: false,
				showworkadd: false,
				workorderCount: 0,
				showrecharge: false,
			};
		},
		onLoad: function(opt) {
			this.opt = app.getopts(opt);
			this.getdata();
		},
		onPullDownRefresh: function() {
			this.getdata();
		},
		methods: {
			getdata: function() {
				var that = this;
				that.loading = true;
				app.get('ApiAdminIndex/index', {}, function(res) {
					that.loading = false;
					that.set = res.set;
					that.uinfo = res.uinfo;
					that.count0 = res.count0;
					that.count1 = res.count1;
					that.count2 = res.count2;
					that.count3 = res.count3;
					that.count4 = res.count4;
					that.seckillCount = res.seckillCount;
					that.collageCount = res.collageCount;
					that.luckycollageCount = res.luckycollageCount;
					that.kanjiaCount = res.kanjiaCount;
					that.tuangouCount = res.tuangouCount;
					that.scoreshopCount = res.scoreshopCount;
					that.yuyueCount = res.yuyueCount;
					that.maidanCount = res.maidanCount;
					that.productCount = res.productCount;
					that.hexiaoCount = res.hexiaoCount;
					that.formlogCount = res.formlogCount;
					that.auth_data = res.auth_data;
					that.showbusinessqr = res.showbusinessqr;
					that.yuyueorderCount = res.yuyueorderCount;
					that.workordercount = res.workordercount;
					that.showshoporder = res.showshoporder;
					that.showcollageorder = res.showcollageorder;
					that.showkanjiaorder = res.showkanjiaorder;
					that.showseckillorder = res.showseckillorder;
					that.showtuangouorder = res.showtuangouorder;
					that.showscoreshoporder = res.showscoreshoporder;
					that.showluckycollageorder = res.showluckycollageorder;
					that.showformlog = res.showformlog;
					that.showworkorder = res.showworkorder;
					that.showworkadd = res.showworkadd;
					that.showyuyueorder = res.showyuyueorder;
					that.showrecharge = res.showrecharge;
					that.loaded();
				});
			},
			switchchange: function(e) {
				console.log(e);
				var field = e.currentTarget.dataset.type;
				var value = e.detail.value ? 1 : 0;
				app.post('ApiAdminIndex/setusertmpl', {
					field: field,
					value: value
				}, function(data) {});
			},
			saoyisao: function(d) {
				var that = this;
				if (app.globalData.platform == 'h5') {
					app.alert('Please use the WeChat scan function to scan the code to write off');
					return;
				} else if (app.globalData.platform == 'mp') {
					var jweixin = require('jweixin-module');
					jweixin.ready(function() { //需在用户可能点击分享按钮前就先调用
						jweixin.scanQRCode({
							needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
							scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码，默认二者都有
							success: function(res) {
								var content = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
								var params = content.split('?')[1];
								app.goto('/admin/hexiao/hexiao?' + params);
								//if(content.length == 18 && (/^\d+$/.test(content))){ //是十八位数字 付款码
								//	location.href = "{:url('shoukuan')}/aid/{$aid}/auth_code/"+content
								//}else{
								//	location.href = content;
								//}
							}
						});
					});
				} else {
					uni.scanCode({
						success: function(res) {
							console.log(res);
							var content = res.result;
							var params = content.split('?')[1];
							app.goto('/admin/hexiao/hexiao?' + params);
						}
					});
				}
			}
		}
	};
</script>
<style>
	@import "../common.css";

	.banner {
		display: flex;
		width: 100%;
		height: 352rpx;
		padding: 40rpx 32rpx;
		color: #fff;
		position: relative
	}

	.banner image {
		width: 120rpx;
		height: 120rpx;
		border-radius: 50%;
		margin-right: 20rpx
	}

	.banner .info {
		display: flex;
		flex: auto;
		flex-direction: column;
		padding-top: 10rpx
	}

	.banner .info .nickname {
		font-size: 32rpx;
		font-weight: bold;
		padding-bottom: 12rpx
	}

	.banner .set {
		width: 70rpx;
		height: 100rpx;
		line-height: 100rpx;
		font-size: 40rpx;
		text-align: center
	}

	.banner .set image {
		width: 50rpx;
		height: 50rpx;
		border-radius: 0
	}

	.contentdata {
		display: flex;
		flex-direction: column;
		width: 100%;
		padding: 0 30rpx;
		margin-top: -160rpx;
		position: relative;
		margin-bottom: 20rpx
	}

	.money {
		display: flex;
		width: 100%;
		align-items: center;
		padding: 10rpx 20rpx;
		background: #fff;
	}

	.money .f1 {
		flex: auto
	}

	.money .f1 .t2 {
		color: #ff3300
	}

	.money .f2 {
		background: #fff;
		color: #ff3300;
		border: 1px solid #ff3300;
		height: 50rpx;
		line-height: 50rpx;
		padding: 0 14rpx;
		font-size: 28rpx;
	}

	.score {
		display: flex;
		width: 100%;
		align-items: center;
		padding: 10rpx 20rpx;
		background: #fff;
		border-top: 1px dotted #eee
	}

	.score .f1 .t2 {
		color: #ff3300
	}

	.order {
		width: 100%;
		background: #fff;
		padding: 0 20rpx;
		margin-top: 20rpx;
		border-radius: 16rpx
	}

	.order .head {
		display: flex;
		align-items: center;
		width: 100%;
		padding: 10rpx 0;
		border-bottom: 0px solid #eee
	}

	.order .head .f1 {
		flex: auto;
		color: #333
	}

	.order .head .f2 {
		display: flex;
		align-items: center;
		color: #FC5648;
		width: 200rpx;
		padding: 10rpx 0;
		text-align: right;
		justify-content: flex-end
	}

	.order .head .f2 image {
		width: 30rpx;
		height: 30rpx;
	}

	.order .head .t3 {
		width: 40rpx;
		height: 40rpx;
	}

	.order .content {
		display: flex;
		width: 100%;
		padding: 10rpx 0;
		align-items: center;
		font-size: 24rpx
	}

	.order .content .item {
		padding: 10rpx 0;
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		position: relative
	}

	.order .content .item image {
		width: 50rpx;
		height: 50rpx
	}

	.order .content .item .t3 {
		padding-top: 3px;
		color: #333
	}

	.order .content .item .t2 {
		background: red;
		color: #fff;
		border-radius: 50%;
		padding: 0 10rpx;
		position: absolute;
		top: 0px;
		right: 40rpx;
		width: 34rpx;
		height: 34rpx;
		text-align: center;
	}

	.agent {
		width: 100%;
		background: #fff;
		padding: 0px 20rpx;
		margin-top: 20rpx
	}

	.agent .head {
		display: flex;
		align-items: center;
		width: 100%;
		padding: 10rpx 0;
		border-bottom: 1px solid #eee
	}

	.agent .head .f1 {
		flex: auto;
	}

	.agent .head .f2 {
		display: flex;
		align-items: center;
		color: #999;
		width: 200rpx;
		padding: 10rpx 0;
		text-align: right;
		justify-content: flex-end
	}

	.agent .head .f2 image {
		width: 30rpx;
		height: 30rpx;
	}

	.agent .head .t3 {
		width: 40rpx;
		height: 40rpx;
	}

	.agent .content {
		display: flex;
		width: 100%;
		padding: 10rpx 0;
		align-items: center;
		font-size: 24rpx
	}

	.agent .content .item {
		padding: 10rpx 0;
		flex: 1;
		display: flex;
		flex-direction: column;
		align-items: center;
		position: relative
	}

	.agent .content .item image {
		width: 50rpx;
		height: 50rpx
	}

	.agent .content .item .t3 {
		padding-top: 3px
	}

	.agent .content .item .t2 {
		background: red;
		color: #fff;
		border-radius: 50%;
		padding: 0 10rpx;
		position: absolute;
		top: 0px;
		right: 40rpx;
	}

	.list {
		width: 100%;
		background: #fff;
		margin-top: 20rpx;
		padding: 0 20rpx;
		font-size: 30rpx;
		border-radius: 16rpx
	}

	.list .item {
		height: 100rpx;
		display: flex;
		align-items: center;
		border-bottom: 0px solid #eee
	}

	.list .item:last-child {
		border-bottom: 0;
	}

	.list .f1 {
		width: 50rpx;
		height: 50rpx;
		line-height: 50rpx;
		display: flex;
		align-items: center;
	}

	.list .f1 image {
		width: 40rpx;
		height: 40rpx;
	}

	.list .f1 span {
		width: 40rpx;
		height: 40rpx;
		font-size: 40rpx
	}

	.list .f2 {
		color: #222
	}

	.list .f3 {
		color: #FC5648;
		text-align: right;
		flex: 1;
	}

	.list .f4 {
		width: 24rpx;
		height: 24rpx;
	}

	.recharge {
		background: #fff;
		width: 100rpx;
		color: #FB6534;
		text-align: center;
		font-size: 20rpx;
		padding: 5rpx;
		border-radius: 10rpx;
		margin-top: 10rpx;
	}

	switch {
		transform: scale(.7);
	}
</style>
